tt'z Guide to PHP Coding! SETTING UP PHP ON YOUR PC  - Go to php.net/downloads.php  - At the top of screen select use for web development  - Then Select I work with Windows, Windows ZIP Downloads, and use OS default version  - Scroll to the x64 Thread safe version and download the ZIP  - Go to file explorer and find where you saved the ZIP, extract it  - Rename the file to php-[version] example: php-8.4.1  - Move the folder to the root of your C: drive  - Copy the file path of the folder in your C: drive. example: C:\php-8.4.1    - Windows search for Edit the system environment variables and open it  - Click the environment variables button at the bottom of the popup  - If you want to setup php for only the current user, select Path in User variables and click edit  - If you want to setup php for the entire system, select Path in System variables and click edit  - On a new line, paste in the variable path you copied previously (C:\php-8.4.1) , click OK  - You can now close all the windows PHP COMMANDS IN COMMAND PROMPT * in CMD, use \ to escape a character or multiple characters, this interoperates it literally instead of using it as a command* * ex: php -r "echo \"Hello\";" escapes the "" to be read as something to echo instead of something read as php code * the \\ will escape characters between them, as well as the one character outside the second \ * ex: php -r "echo \"Hello\";" will run as echo "Hello"; which would not be possible otherwise php -version : Gives information about the installed version of php php -v : Gives information about the installed version of php php -m : Gives list of all loaded modules/extensions php -i : Shows complete PHP configuration php -r "" : Runs php code inside command prompt. On windoes CMD you must use double quotes ("") outside the code ex : php -r "echo 'hello';" cd : Not a php command, but changes current directory to the directory typed. Must use before using php -S command ex : cd E:\ttz-thingz\projects\public_html php -S localhost:[port] : Starts a php server on your local network ex : php -S localhost:7777 opens a server on port 7777 *Use Ctrl + M1 on the link to open it in your default browser *Use Ctrl + C to shutdown the server when in Command Prompt *You can also use the start command as the stop command, using the same port *Some ports are unsafe to use, those are : 1, 7, 9, 11, 13, 19, 21, 23, 25, 37, 53, 67, 69, 79, 87, 95, 101, 102, 108, 109, 110, 115, 119, 123, 137, 138, 139, 161, 162, 194, 220, 515, 587, 631, 993, 995 PHP INFO AND SYNTAX IN WEB - php files use .php as their extension - start using php in a php file with : ) out when using only php in a php file DATA TYPES IN PHP 1) Integers Positive Integer: $x = 100; Use var_dump([integer]) to get value and information about a integer ex: var_dump($x); will output: int(100) Negative Integer: $y =-100; var_dump($y); will output: int(-100) You can also dump multiple variables (2 or more) var_dump($x, $y) will output: int(100) int(-100) 2) Strings String: $msg = "lol wtf"; Dumping strings will output type, length, and contents var_dump($msg); will output: string(7) "lol wtf" 3) Floats (Doubles) $double = 43.12; $double2 = 4312.01; var_dump($double) will output: float(43.12) 4) Boolean A Boolean with the type false $boolean_true = FALSE; A Boolean with the type true $boolean_false = true; var_dump($boolean_true, $boolean_false); will output: bool(false) bool(true) 5) Arrays You can establish arrays using () or [] An array can have integers, strings, doubles, booleans, functions, arrays, objects Arrays start at 0. The first item in an array is the place of 0 Using () $array_test = array("bruh", 8, "92a", 40.12, FALSE); Using [] $array_yippe = ["bruh", "gw2", "h1z1", "hi-c"]; Dumping an array shows # of items, item place in the array, & the usual info dump of that item. It will do this for all items var_dump($array_yippe); will output: array(4) { [0]=> string(4) "bruh" [1]=> string(8) "fortnite" [2]=> string(4) "h1z1" [3]=> string(4) "hi-c" } var_dump($array_test); will output: array(5) { [0]=> string(4) "bruh" [1]=> int(8) [2]=> string(3) "92a" [3]=> float(40.12) [4]=> bool(false) } 6) Classes Establish a class like this: class nameOfClass { } You can create variables in a class that can be accesed anywhere using public before the variable: class nameOfClass { public $everywhere = "this can go anywhere"; } You can call the variable in the same class it was created in by using this: class nameOfClass { public $everywhere = "this can go anywhere"; function sayThat() { echo "{$this->everywhere}"; } } Inside a class, you define methods and properties You don’t run code directly in the class body (outside of functions) To execute methods, you need to create an object instance of the class, then call the method using -> Making an object: $thisIsAnObject = new nameOfClass; Calling a function from the class: $thisIsAnObject->sayThat(); will output: this can go anywhere var_dump(thisIsAnObject); will output: object(nameOfClass)#1 (1) { ["everywhere"]=> string(20) "this can go anywhere" } Entire class completed: class NameOfClass { public $everywhere = "this can go anywhere"; function sayThat() { echo "{$this->everywhere}"; } } $thisIsAnObject = new NameOfClass(); $thisIsAnObject->sayThat(); var_dump($thisIsAnObject); Output of the code snipped above: this can go anywhereobject(nameOfClass)#1 (1) { ["everywhere"]=> string(20) "this can go anywhere" } 7) NULL Start with a normal variable (You dont have to) $x = "bruh"; var_dump($x); will output: string(4) "bruh" Then Redefine x as NULL & dumo again $x = NULL; var_dump($x); will output: NULL